package gx.entity;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;


@Entity
@Table(name = "t_purchase")
public class Purchase { 
	@Id
	@GeneratedValue
	private Integer id;  //采购订单编号
	private BigDecimal cost; // 采购总金额
	private Integer pay_type; //采购支付类    0：全款 1：欠款   均为现金支付
	private Date pur_date;  //采购时间
	@Lob
	private String remark; //备注
	private String sn; //采购订单序列号
    private Integer  status; //采购状态0:草稿  1：已下单  2：已入库  3：退货
	
    //映射关系
    //采购订单 - 管理员   多对一
    @ManyToOne
    @JoinColumn(name="mgr_id")
    private Manager manager;
    
    //todo
    //采购订单--供应商 多对一
    @ManyToOne
    @JoinColumn(name="supp_id")
    private Supplier supplier;
    
    
    
  
	//商品到采购订单项的一对多
    @OneToMany(mappedBy = "product")
    @JsonIgnore
    //生成Json字符串时忽略此属性
    private List<PurchaseItem> purchaseItems = new ArrayList<PurchaseItem>();
    
    //订单到订单项的一对多
    @OneToMany(cascade = { CascadeType.ALL})
    @JoinColumn(name = "purc_id")
    private List<PurchaseItem> itemList =  new ArrayList<PurchaseItem>();

	public List<PurchaseItem> getPurchaseItems() {
		return purchaseItems;
	}
	public void setPurchaseItems(List<PurchaseItem> purchaseItems) {
		this.purchaseItems = purchaseItems;
	}
	public List<PurchaseItem> getItemList() {
		return itemList;
	}
	public void setItemList(List<PurchaseItem> itemList) {
		this.itemList = itemList;
	}
	public Supplier getSupplier() {
		return supplier;
	}
	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}
	public Manager getManager() {
		return manager;
	}
	public void setManager(Manager manager) {
		this.manager = manager;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public BigDecimal getCost() {
		return cost;
	}
	public void setCost(BigDecimal cost) {
		this.cost = cost;
	}
	public Integer getPay_type() {
		return pay_type;
	}
	public void setPay_type(Integer pay_type) {
		this.pay_type = pay_type;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getSn() {
		return sn;
	}
	public void setSn(String sn) {
		this.sn = sn;
	}
	
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Date getPur_date() {
		return pur_date;
	}
	public void setPur_date(Date pur_date) {
		this.pur_date = pur_date;
	}

	
    
    

}
